package main

/*
#include <stdio.h>

void say_hello_with_name(char *name)
{
	printf("hello %s\n", name);
}

unsigned long *array(unsigned short list[])
{
	static unsigned long out[4];
	for (int i = 0; i < 4; i++) {
		out[i] = list[i] + 1;
	}
	return &out[0];
}
*/
import "C"

import (
	"fmt"
	"unsafe"
)

func main() {
	C.say_hello_with_name(C.CString("oscar"))
	data :=[]uint16{1, 2, 3, 4}
	var pwd []uint32
	size := 4
	var param []C.ushort

	for _, v := range data {
		param = append(param, C.ushort(v))
	}
	out := C.array(&param[0])
	ptr := unsafe.Pointer(out)
	for i := 0; i < size; i++ {
		vptr := unsafe.Pointer(uintptr(ptr) + uintptr(i) * unsafe.Sizeof(C.ulong(1)))
		pwd = append(pwd, uint32(*(*C.ulong)(vptr)))
	}
	fmt.Println(pwd)
}
